// 引用数据类型 Object(object/array/function)
let a:object;
// a = 1;
a = [];
a = {};
a = function(){};

/**
 * 对象：
 * {
 *  属性名:属性值
 * ...
 * 在属性后 添加问号  相当于给当前属性设置可选开关
 * }
 */
let b:{
    a:number;
    c:string;
    d?:boolean
    // 可以添加任意属性 任意类型
    // 接口属性添加一个[propName:string]:any，使得实例化对象中任意添加属性名是string类型，属性值为any类型的属性
    [propName:string]: any
    // [aaa:string]: any
    // [bbb:string]: any
    // [ccc:string]: any
};

b = {
    a:12,
    c:'111',

};
b = {
    a:123,
    c:'103',
    d:true
};
b = {
    a:14,
    c:'10',
    d:true,
    e:111,
    f:'1112',
    g:true
};

/**
 * 函数
 *
 */
let g:(a:number,b:number) => number;

g = function fn1(a,b){
    console.log(a + b);
    return a + b;
};

g(8,9);

/**数组
 * let xxx:type[];
 * let yyy:Array<type>
 */
let x:string[];
x = ['1','2','3'];
x = ['1','2','3','555'];
// x = [1,2,3,]

let y:Array<boolean>;
y = [true,false,true,true];

// 元祖：固定长度的数组
let z:[number,boolean,number];

z = [12,true,177];

// 枚举
enum Sex{
    man,
    woman,
}

let o:{
    name:string;
    age:number;
    sex:Sex;
};

o = {
    name:'LiLi',
    age:13,
    sex:Sex.woman
};

console.log(o.sex === Sex.man?'男':'女');

// 类型别名
type myType = 1|2|3|4;
let p:myType = 2;
p = 1;
p = 3;
p = 4;
// p = 5;

// 逻辑运算符 &  拼接
let r:{name:string}&{age:number}&{sex:string};

r = {
    name:'孙悟空',
    age:500,
    sex:'男'
};

export {};

